package com.itggm.service.impl;


import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.itggm.DTO.LogInfoPageDTO;
import com.itggm.mapper.LogInfoMapper;
import com.itggm.pojo.LogInfo;
import com.itggm.response.ResponseResult;
import com.itggm.service.LogInfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

 /**
  * @Author: ggm
  * @date:  2024/11/24
  * 日志管理
  */

@Service
public class LogInfoServiceImpl implements LogInfoService {

    @Autowired
    private LogInfoMapper logInfoMapper;


    @Override
    public ResponseResult logInfoPage(LogInfoPageDTO logInfoPageDTO) {


        PageHelper.startPage(logInfoPageDTO.getPage(),logInfoPageDTO.getLimit());
        List<LogInfo> tableData =  logInfoMapper.selectLogInfos(logInfoPageDTO.getDescription(),logInfoPageDTO.getModel());
        long total = new PageInfo<LogInfo>(tableData).getTotal();

        return ResponseResult.success().data(tableData).count(total);
    }

    @Transactional
    @Override
    public ResponseResult deleteLogInfo(List<Integer> ids) {

        logInfoMapper.deleteLogInfo(ids);

        return ResponseResult.success();
    }
}
